home *** CD-ROM | disk | FTP | other *** search
/ MacAddict 83 / MacAddict_083_2003-07.iso / mac / Software / Development / VLC Source 0.5.3.dmg / src / misc / win32_specific.c < prev   
C/C++ Source or Header  |  2003-04-07  |  5KB  |  143 lines

  1. /*****************************************************************************
  2.  * win32_specific.c: Win32 specific features
  3.  *****************************************************************************
  4.  * Copyright (C) 2001 VideoLAN
  5.  * $Id: win32_specific.c,v 1.22 2003/03/03 14:21:08 gbazin Exp $
  6.  *
  7.  * Authors: Samuel Hocevar <sam@zoy.org>
  8.  *          Gildas Bazin <gbazin@netcourrier.com>
  9.  *
  10.  * This program is free software; you can redistribute it and/or modify
  11.  * it under the terms of the GNU General Public License as published by
  12.  * the Free Software Foundation; either version 2 of the License, or
  13.  * (at your option) any later version.
  14.  *
  15.  * This program is distributed in the hope that it will be useful,
  16.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  18.  * GNU General Public License for more details.
  19.  *
  20.  * You should have received a copy of the GNU General Public License
  21.  * along with this program; if not, write to the Free Software
  22.  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  23.  *****************************************************************************/
  24. #include <string.h>                                              /* strdup() */
  25. #include <stdlib.h>                                                /* free() */
  26.  
  27. #include <vlc/vlc.h>
  28.  
  29. #if !defined( UNDER_CE )
  30. #   include <fcntl.h>
  31. #   include <winsock2.h>
  32. #endif
  33.  
  34. /*****************************************************************************
  35.  * system_Init: initialize winsock and misc other things.
  36.  *****************************************************************************/
  37. void system_Init( vlc_t *p_this, int *pi_argc, char *ppsz_argv[] )
  38. {
  39. #if !defined( UNDER_CE )
  40.     WSADATA Data;
  41.  
  42.     /* Get our full path */
  43.     if( ppsz_argv[0] )
  44.     {
  45.         char psz_path[MAX_PATH];
  46.         char *psz_vlc;
  47.  
  48.         GetFullPathName( ppsz_argv[0], MAX_PATH, psz_path, &psz_vlc );
  49.  
  50.         if( psz_vlc > psz_path && psz_vlc[-1] == '\\' )
  51.         {
  52.             psz_vlc[-1] = '\0';
  53.             p_this->p_libvlc->psz_vlcpath = strdup( psz_path );
  54.         }
  55.         else
  56.         {
  57.             p_this->p_libvlc->psz_vlcpath = strdup( "" );
  58.         }
  59.     }
  60.     else
  61.     {
  62.         p_this->p_libvlc->psz_vlcpath = strdup( "" );
  63.     }
  64.  
  65.     /* Set the default file-translation mode */
  66.     _fmode = _O_BINARY;
  67.  
  68.     /* WinSock Library Init. */
  69.     if( !WSAStartup( MAKEWORD( 2, 0 ), &Data ) )
  70.     {
  71.         /* Confirm that the WinSock DLL supports 2.0.*/
  72.         if( LOBYTE( Data.wVersion ) != 2 || HIBYTE( Data.wVersion ) != 0 )
  73.         {
  74.             /* We could not find a suitable WinSock DLL. */
  75.             WSACleanup( );
  76.         }
  77.         else
  78.         {
  79.             /* Everything went ok. */
  80.             return;
  81.         }
  82.     }
  83.  
  84.     /* Let's try with WinSock 1.1 */
  85.     if( !WSAStartup( MAKEWORD( 1, 1 ), &Data ) )
  86.     {
  87.         /* Confirm that the WinSock DLL supports 1.1.*/
  88.         if( LOBYTE( Data.wVersion ) != 1 || HIBYTE( Data.wVersion ) != 1 )
  89.         {
  90.             /* We could not find a suitable WinSock DLL. */
  91.             WSACleanup( );
  92.         }
  93.         else
  94.         {
  95.             /* Everything went ok. */
  96.             return;
  97.         }
  98.     }
  99.  
  100.     fprintf( stderr, "error: can't initialize WinSocks\n" );
  101.  
  102.     return; 
  103.  
  104. #endif
  105. }
  106.  
  107. /*****************************************************************************
  108.  * system_Configure: check for system specific configuration options.
  109.  *****************************************************************************/
  110. void system_Configure( vlc_t *p_this )
  111. {
  112. #if !defined( UNDER_CE )
  113.     p_this->p_libvlc->b_fast_mutex = config_GetInt( p_this, "fast-mutex" );
  114.     p_this->p_libvlc->i_win9x_cv = config_GetInt( p_this, "win9x-cv-method" );
  115.  
  116.     /* Raise default priority of the current process */
  117. #ifndef ABOVE_NORMAL_PRIORITY_CLASS
  118. #   define ABOVE_NORMAL_PRIORITY_CLASS 0x00008000
  119. #endif
  120.     if( !SetPriorityClass( GetCurrentProcess(),
  121.                ABOVE_NORMAL_PRIORITY_CLASS ) )
  122.     {
  123.         if( !SetPriorityClass( GetCurrentProcess(),
  124.                    HIGH_PRIORITY_CLASS ) )
  125.         msg_Dbg( p_this, "can't raise process priority" );
  126.     else
  127.         msg_Dbg( p_this, "raised process priority" );
  128.     }
  129.     else
  130.     msg_Dbg( p_this, "raised process priority" );
  131. #endif
  132. }
  133.  
  134. /*****************************************************************************
  135.  * system_End: terminate winsock.
  136.  *****************************************************************************/
  137. void system_End( vlc_t *p_this )
  138. {
  139. #if !defined( UNDER_CE )
  140.     WSACleanup();
  141. #endif
  142. }
  143.